package plp.funcoo.facade;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

import parser.FuncOOparser;
import parser.ParseException;
import plp.funcoo.exceptions.ClassAlreadyDeclared;
import plp.funcoo.exceptions.ClassNotDeclared;
import plp.funcoo.exceptions.ConstructorNotDeclared;
import plp.funcoo.exceptions.InvalidInput;
import plp.funcoo.exceptions.MethodAlreadDeclared;
import plp.funcoo.exceptions.MethodNotDeclared;
import plp.funcoo.exceptions.ParameterNumberIncorrect;
import plp.funcoo.exceptions.ParameterTypeIncorrect;
import plp.funcoo.exceptions.VarAlreadyDeclared;
import plp.funcoo.exceptions.VarNotDeclared;

public class Facade {

	private static  Facade facade = null;
	private static FuncOOparser parser = null;
	
	public Facade()
	{
		 InputStream is = new ByteArrayInputStream("dd".getBytes());
	}
	
	public static Facade gerInstance()
	{
		if(facade == null)
		{
			facade = new Facade();
			parser = new FuncOOparser(System.in);
		}
		
		return facade;
	
	}
	
	public String execute(String code) throws VarNotDeclared, VarAlreadyDeclared, MethodNotDeclared, MethodAlreadDeclared, ClassNotDeclared, ClassAlreadyDeclared, ConstructorNotDeclared, InvalidInput, ParseException, ParameterTypeIncorrect, ParameterNumberIncorrect
	{
		return this.parser.analysis(code);
	}
	
	public String execute(String code,String input) throws VarNotDeclared, VarAlreadyDeclared, MethodNotDeclared, MethodAlreadDeclared, ClassNotDeclared, ClassAlreadyDeclared, ConstructorNotDeclared, InvalidInput, ParseException, ParameterTypeIncorrect, ParameterNumberIncorrect
	{
		return this.parser.analysis(code,input);
	}
	
	public String executeConsole()
	{
		//return this.parser.analysis(code);
		return null;
	}
	
	
}
